package com.frxuexi.lib_base.room

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

@Dao
interface ParkDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun addPark(entity: ParkEntity):Long

    @Query("select * from park where date=:date")
    fun getParksByDate(date:String):List<ParkEntity>

    @Query("select count(*) from park where date=:date")
    fun getCountByDate(date:String):Int

    @Query("select * from park where date like '%' || :para || '%' or carNum like '%' || :para || '%'")
    fun getParksByDateOrNum(para:String):List<ParkEntity>

    @Query("select * from park where id=:id")
    fun getParksById(id:Long):ParkEntity

    @Delete
    fun deletePark(entity: ParkEntity):Int

    @Update
    fun update(entity: ParkEntity):Int

//    0,9
    @Query("select * from park order by id desc limit :offset*:size,:size*:offset+:size-1")
    fun getParks(size:Int,offset:Int):List<ParkEntity>

}